-- drunken_master
-- created by wangy
-- 攻击概率造成额外伤害(醉拳)

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 对敌伤害触发
    trigger = function(who, prop, arg)
        local extraDamage = 0;
        if tonumber(prop[2]) > 0 then
            extraDamage = math.modf(prop[2] * arg / 1000);
        else
            extraDamage = who:queryAttrib(prop[2]);
        end

        if DungeonM.getRandSeed("probability_damage") % 1000 >= prop[3] then
            return 0;
        end

        -- 触发特技发动事件
        local target = who.dbase:queryTemp("defenser_info")["target"];
        local targetPos;
        if target and target.type == OBJECT_TYPE_MONSTER then
            targetPos = target:getOwner();
        end
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1], pos = targetPos, });

        return math.max(1, extraDamage);
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;
        local ron = tonumber(prop[3]) / 10;
        local add = 100 + tonumber(prop[2]) / 10;

        desc = string.gsub(desc, "{0}", add);
        desc = string.gsub(desc, "{1}", ron);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};
